
/*
指示器接口
指示器包括蜂鸣器和LED灯。
*/

#ifndef _INDECATOR_H__
#define _INDECATOR_H__

#include <stdint.h>

#if 0
enum{
	Inde_Buzzer = 0,
	Inde_Light = 1,
	Inde_MAX,
};
#endif 

enum {
	Setting_Permanent,
	Setting_Temp,
	Setting_MAX,
};

enum {
	State_Off,
	State_On,
	State_MAX,
};


typedef struct {
	uint32_t objId;
	void(*action)(uint32_t, uint32_t);
}IndecatorObject_T;

typedef struct {
	uint32_t state;	//状态
	uint16_t time;	//状态持续时间，0表示无效状态
}IndecatorState_T;

typedef struct {
	IndecatorState_T states[State_MAX];	//状态表：下标0为Off，1为On
	uint32_t duration;			//设置有效时间，0表示永久
	uint8_t current;			//配置当前状态的下标，0或1
}IndecatorSetting_T;

typedef struct {
	IndecatorObject_T obj;
	IndecatorSetting_T settings[Setting_MAX];	//指示器配置表：常态配置和临时配置
	uint32_t stateTick;							//用于状态计时
	uint32_t settingTick;						//用于配置计时
	uint8_t current;							//当前配置
}Indecator_T;


void Indecator_Init(void);

void Indecator_Unregister(Indecator_T* indecator);

int Indecator_Register(Indecator_T* indecator);


void Indecator_Attach(Indecator_T* indecator, const IndecatorObject_T* obj);

void Indecator_Set(Indecator_T* indecator, uint8_t activeSetting, const IndecatorSetting_T* permanent, const IndecatorSetting_T* temp);


#endif /* _INDECATOR_H__ */

